package net.martus.utils
{
	import flash.filesystem.File;
	
	public class DirectoryUtils
	{
		public function DirectoryUtils()
		{
		}
		
		public static function path(str:String):String
		{
			var result:String = str;
			var pos:int = -1;
			
			pos = result.lastIndexOf(File.separator);
			if( pos < 0 )
			{
				return result;
			}
			
			result = result.substr(0, pos + 1);
			
			return result;
		}
		
		public static function name(str:String):String
		{
			var result:String = str;
			var pos:int = -1;
			
			pos = result.lastIndexOf(File.separator);
			if( pos < 0 )
			{
				return result;
			}
			
			result = result.substr(pos + 1);

			pos = result.lastIndexOf(".");
			if( pos < 0 )
			{
				return result;
			}
			
			result = result.substr(0, pos);

			return result;
		}
		
		public static function ext(str:String):String
		{
			var result:String = str;
			var pos:int = -1;
			
			pos = result.lastIndexOf(".");
			if( pos < 0 )
			{
				return result;
			}
			
			result = result.substr(pos + 1);
			
			return result;
		}
	}
}